package iii.myangel;

import java.io.File;
import java.io.FileInputStream;
import java.util.LinkedList;

import packet.SendPicSound;

import android.app.Activity;
import android.net.Uri;
import android.os.Environment;

public class SendFile extends Activity{
	public void SentFile(String name){
		SendPicSound o=new SendPicSound();
		String path="";
		FileInputStream fis=null;
		try{
		File imageDir = Environment
				.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
		path = Uri.fromFile(new File(imageDir, name)).toString();
		
		fis=new FileInputStream(path);
		byte[] bytes=new byte[1024];
		byte[] bb=null;
		LinkedList<byte[]> bList=new LinkedList<byte[]>();
		int n=0;
		while((n=fis.read(bytes))!=-1){
			bb=new byte[n];
			for(int i=0;i<n;i++){
				bb[i]=bytes[i];
			}
			bList.add(bb);
		}
		o.name=name;
		o.setlist(bList);
		MainActivity.lcl.send(o);
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
}
